using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using BanHangCshap.Class;
namespace BanHangCshap
{
    public partial class frmChucNang : DevExpress.XtraEditors.XtraForm
    {
        ChucNang cls = new ChucNang();
        public Boolean issua = false;
        public string macn = "";
        public delegate void GetDataTable();
        public GetDataTable loadChucNang;
        public frmChucNang()
        {
            InitializeComponent();
        }

        private void frmChucNang_Load(object sender, EventArgs e)
        {
            NhomChucNang clsnhomcn = new NhomChucNang();
            glkuNhomCN.Properties.DataSource = clsnhomcn.layDSNhomChucNang();
            glkuNhomCN.Properties.DisplayMember = "tennhomcn";
            glkuNhomCN.Properties.ValueMember = "manhomcn";
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnLuuLai_Click(object sender, EventArgs e)
        {
            cls.manhomcn = glkuNhomCN.EditValue.ToString().Trim();
            cls.macn = txtMa.Text.Trim();
            cls.tencn = txtTen.Text.Trim();
            Boolean ok = false;
            if (!issua) ok = cls.themChucNang();
            if (ok)
            {
                loadChucNang();
                txtMa.Text = "";
                txtTen.Text = "";
                txtMa.Focus();
            }

        }
    }
}